import 'package:flutter/material.dart';
import 'package:x3_base_package/x3_base_package.dart';

class BusinessDepotStyleDetailsInformationTab extends StatelessWidget {
  BusinessDepotStyleDetailsInformationTab({Key key, @required this.styleId}) : super(key: key);

  final String styleId;

  @override
  Widget build(BuildContext context) {
    return BaseCardComponent(
      child: BaseScreenRefreshComponent(
        request: new BaseScreenRequestModel('/bi/report/app/query/query/style/info/{styleId}', params: {'styleId': styleId}, method: BaseHttpMethodEnum.GET),
        builder: (BaseHttpResultModel result) {
          List<dynamic> items = result.data;
          return ListView(
            children: items.map((item) => _buildBaseInformationItem(context, item)).toList(),
          );
        },
      ),
    );
  }

  Widget _buildBaseInformationItem(BuildContext context, dynamic item) {
    String name = BaseUtils.getKeyData(item, 'name').toString();
    List<dynamic> values = item['values'];
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          padding: EdgeInsets.symmetric(vertical: 8.0,horizontal: 8.0),
          child: Text(name, style: TextStyle(color: Color(0xFF333333),fontSize: 14)),
        ),
        Container(
          padding: EdgeInsets.only(left: 8.0, bottom: 8.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: values.map((e) {
              String name = BaseUtils.getKeyData(e, 'name').toString();
              String value = BaseUtils.getKeyData(e, 'value').toString();
              return Container(
                padding: EdgeInsets.symmetric(vertical: 4.0),
                child: BaseComponentUtils.buildTextSpanWidget(
                  ['$name:', value],
                  styles: {0: Theme.of(context).textTheme.subtitle2, 1: Theme.of(context).textTheme.subtitle2},
                ),
              );
            }).toList(),
          ),
        ),
        BaseComponentUtils.buildHorizontalDivider(),
      ],
    );
  }
}
